/*
 * sccb.h
 *
 *  Created on: May 24, 2021
 *      Author: kirk_
 */

#ifndef SCCB_H_
#define SCCB_H_

#include "main.h"

//IO方向设置
#define SCCB_SDA_IN()  {GPIOH->MODER&=~(3<<(13*2));GPIOH->MODER|=0<<13*2;}	//PB3输入模式
#define SCCB_SDA_OUT() {GPIOH->MODER&=~(3<<(13*2));GPIOH->MODER|=1<<13*2;}    //PB3输出模式
//IO操作
#define SCCB_SCL(n)  (n?HAL_GPIO_WritePin(GPIOH,SCCB_SCL_Pin,GPIO_PIN_SET):HAL_GPIO_WritePin(GPIOH,SCCB_SCL_Pin,GPIO_PIN_RESET)) //SCL
#define SCCB_SDA(n)  (n?HAL_GPIO_WritePin(GPIOH,SCCB_SDA_Pin,GPIO_PIN_SET):HAL_GPIO_WritePin(GPIOH,SCCB_SDA_Pin,GPIO_PIN_RESET)) //SDA

#define SCCB_READ_SDA    HAL_GPIO_ReadPin(GPIOH,SCCB_SDA_Pin)     //输入SDA
#define SCCB_ID         0X60                                    //OV2640的ID

///////////////////////////////////////////

void SCCB_Start(void);
void SCCB_Stop(void);
void SCCB_No_Ack(void);
uint8_t SCCB_WR_Byte(uint8_t dat);
uint8_t SCCB_RD_Byte(void);
//uint8_t SCCB_WR_Reg(uint8_t reg,uint8_t data);
//uint8_t SCCB_RD_Reg(uint8_t reg);

#endif /* SCCB_H_ */
